package com.mzy.linear_struct.subject;

/**
 * @Author: codermzy
 * @Date: 2024/04/26/下午6:47
 * @Description:
 */
public class 二叉树的最大深度104 {
    class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode() {
        }

        TreeNode(int val) {
            this.val = val;
        }

        TreeNode(int val, TreeNode left, TreeNode right) {
            this.val = val;
            this.left = left;
            this.right = right;
        }
    }

    static class Solution {
        public int maxDepth(TreeNode root) {

            if (root == null) return 0;

            int leftHeight = maxDepth(root.left) + 1;
            int rightHeight = maxDepth(root.right) + 1;
            return Math.max(leftHeight, rightHeight);
        }


    }
}
